package bank;

public class _53MaxSubArray {
    public static int maxSubArray(int[] nums) {
        //  贪心算法
        int res = nums[0],nowMax = 0;
        for (int num : nums){
            nowMax = nowMax < 0 ? Math.max(nowMax,num) : nowMax + num;
            res = Math.max(nowMax,res);
        }
        return res;
    }
}
